<?php

namespace App\Modules\CodeDesigner\Factory;

use App\Modules\CodeDesigner\Factory\Operation\Add;
use App\Modules\CodeDesigner\Factory\Operation\Sub;

class OperationFactory
{
    public function operation(string $operation, int $number1, int $number2): int
    {
        /**
         * @var Operation $op
         */
        switch ($operation) {
            case '+' :
                $op = new Add($number1, $number2);
                break;
            case '-' :
                $op = new Sub($number1, $number2);
                break;
            default:
                throw new \Exception('invalid operation');
        }
       return $op->getResult();
    }
}